<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
<title>Users</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function switchUserType() {
	var switch_user_type = document.getElementById("switch_user_type_button");
	var user_list_span = document.getElementById("user_list");
	var request_url;
	if (switch_user_type.innerHTML == "View Administrators") {
		request_url = "view_admins.jsp";
		switch_user_type.innerHTML = "View Students";
	}
	else {
		request_url = "view_students.jsp";
		switch_user_type.innerHTML = "View Administrators";
	}
	
	
	var request = new XMLHttpRequest();	
	request.open("GET", request_url, false);
	request.send(null);
	
	if(request.status==200){
		user_list_span.innerHTML = request.responseText;
	}      
	else {
		user_list_span.innerHTML = "&lt;i&gt;Cannot load students...&lt;/i&gt;";
	}
}





</script>
</head>
<body onload = "setPage('view_users');switchUserType()">
<%@ include file="WEB-INF/private/body_wrapper_header.html" %>


<% 
if (request.getSession(false) == null || request.getSession(false).getAttribute("username") == null) {
	response.sendError(HttpServletResponse.SC_FORBIDDEN, "Please login first!");
	return;
}

if (!request.getSession(false).getAttribute("type").equals("admin")) {
	response.sendError(HttpServletResponse.SC_FORBIDDEN, "Only admininistrator can manage users");
	return;
}
%>

<h3><a id="switch_user_type_button" href="#" onclick="switchUserType()">View Students</a></h3>
<span id="user_list"></span>




<%@ include file="WEB-INF/private/body_wrapper_footer.html" %>
</body>
</html>